home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Atari Mega Archive 1
/
Atari Mega Archive - Volume 1.iso
/
editors
/
memcs312
/
ue312pl1.zoo
/
st52.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-12-02
|
23KB
|
958 lines
/* ST52.C: Atari ST1040/520 screen support functions
written by lots of people (see below)
Daniel Lawrence
James Turner
Jeff Lomicka
J. C. Benoist
Modification History:
31-dec-87 Jeff Lomicka
- massive changes/additions for accessories and mouse
20-jan-87 Daniel Lawrence
- changed code in domousekey() to pass five bytes, two zeros
(to tell input.c that this is a mouse event), x/ypos
and the mouse event type.
may 88 Jeff Lomicka and Dan Lawrence
- a lot of changes. Through out aline.h, use the MWC and
ATARI names for things now.
- moving the mouse to the extreme upper left brings up
the desk accessory menu. EMACS won't replot on the
way out yet.
- cleaned up behavior of the mouse and the cursor on exit
26-feb-89 Daniel Lawrence
- rewote input layer to conform to new specs in input.c
01-may-91 Daniel Lawrence/Suggested by Allan Pratt
- renamed atari source files to TOS.C and ST52.c
- changed symbols ATARI => ST52 and ST520 => TOS
*/
#define termdef 1 /* don't define "term" external */
#include <stdio.h>
#include "estruct.h"
#include "eproto.h"
#include "edef.h"
#include "elang.h"
#if ST52
/*
These routines provide support for the ATARI 1040ST and 520ST
using the virtual VT52 Emulator
*/
#include <aesbind.h>
#include <gemdefs.h>
#include <obdefs.h>
#include <osbind.h>
#include <bios.h>
#include <xbios.h>
#include <linea.h>
#define NROW 50 /* Screen size. */
#define NCOL 80 /* Edit if you want to. */
#define MARGIN 8 /* size of minimim margin and */
#define SCRSIZ 64 /* scroll size for extended lines */
#define NPAUSE 300 /* # times thru update to pause */
#define BIAS 0x20 /* Origin 0 coordinate bias. */
#define ESC 0x1B /* ESC character. */
#define SCRFONT 2 /* index of 8x16 monochrome system default font */
#define DENSIZE 50 /* # of lines in a dense screen */
/* Palette color definitions */
#define LOWPAL "000700070770007707077777333733373773337737377777"
#define MEDPAL "000700007777"
#define HIGHPAL "111000"
/* ST Global definitions */
int initrez; /* initial screen resolution */
int currez; /* current screen resolution */
int gemflag; /* were we called from the desktop? */
int mouseon; /* True if mouse is on */
char resname[][8] = { /* screen resolution names */
"LOW", "MEDIUM", "HIGH", "DENSE"
};
short spalette[16]; /* original color palette settings */
short palette[16]; /* current palette settings */
static short scursor; /* original text cursor mode */
struct la_data *aline; /* Line A data structure */
struct la_ext *naline; /* extended Line A data structure */
struct la_font **fonts; /* Array of pointers to the three system
font headers returned by init (in register A1) */
struct la_font *system_font; /* pointer to default system font */
struct la_font *small_font; /* pointer to small font */
/*
These are needed to make GEM happy
*/
int contrl[ 11], intin[ 128], intout[ 128], ptsin[ 256], ptsout[ 12];
static int worki[ 11] = {1,1,1,1,1,1,1,1,1,1,2}, worko[ 57];
/*
Some useful information about our environment
*/
static int
g_wchar, g_hchar, /* VDI's idea of current font size */
junk, gid, wkid; /* Graphics ID, workstation ID */
static int w_handle; /* our window's handle */
static Rect w_area; /* our window's area */
static int oldbut = 0; /* Previous state of mouse buttons */
static int mctrl; /* current BEG_MOUSE state */
static struct { char *norm, *shift, *caps;} *kt; /* Keyboard mapping */
/*
This object tree is for displaying the desk accessory menu.
Actual positions are written into this structure when the
screen size is known.
*/
OBJECT menu[] =
{
-1, 1, 4, G_IBOX, NONE, NORMAL, 0x0L, 0 , 0, 0, 0,/* Root */
4, 2, 2, G_BOX, NONE, NORMAL, 0x10F0L, 0, 0, 1, 1,/* BAR */
1, 3, 3, G_IBOX, NONE, NORMAL, 0x0L, 0, 0, 1, 1,/* Active */
2,-1,-1, G_TITLE, NONE, NORMAL, "", 0, 0, 1, 1,/* title */
0, 5, 5, G_IBOX, NONE, NORMAL, 0x0L, 0, 0, 0, 0,/* screen */
4, 6,13, G_BOX, NONE, NORMAL, 0xFF1100L, 0, 0, 0, 0,/* box */
7,-1,-1, G_STRING, NONE, NORMAL, TEXT179,0,0,168, 16,
/* " About MicroEmacs" */
8,-1,-1, G_STRING, NONE,DISABLED, "---------------------",
0, 16, 168, 16,
9,-1,-1, G_STRING, NONE, NORMAL, "", 0, 32, 168, 16,
10,-1,-1, G_STRING, NONE, NORMAL, "", 0, 48, 168, 16,
11,-1,-1, G_STRING, NONE, NORMAL, "", 0, 64, 168, 16,
12,-1,-1, G_STRING, NONE, NORMAL, "", 0, 80, 168, 16,
13,-1,-1, G_STRING, NONE, NORMAL, "", 0, 96, 168, 16,
5,-1,-1, G_STRING, LASTOB, NORMAL, "", 0,112, 168, 16
};
static int mousecol = HUGE; /* current mouse column */
static int mouserow = HUGE; /* current mouse row */
extern int ttopen(); /* Forward references. */
extern int ttgetc();
extern int ttputc();
extern int ttflush();
extern int ttclose();
extern int stmove();
extern int steeol();
extern int steeop();
extern int stbeep();
extern int stopen();
extern int stclose();
extern int stgetc();
extern int stputc();
extern int strev();
extern int strez();
extern int stkopen();
extern int stkclose();
#if COLOR
extern int stfcol();
extern int stbcol();
#endif
/*
* Dispatch table. All the
* hard fields just point into the
* terminal I/O code.
*/
TERM term = {
NROW-1,
NROW-1,
NCOL,
NCOL,
0, 0,
MARGIN,
SCRSIZ,
NPAUSE,
&stopen,
&stclose,
&stkopen,
&stkclose,
&stgetc,
&stputc,
&ttflush,
&stmove,
&steeol,
&steeop,
&steeop,
&stbeep,
&strev,
&strez
#if COLOR
, &stfcol,
&stbcol
#endif
};
/* input buffers and pointers */
#define IBUFSIZE 64 /* this must be a power of 2 */
unsigned char in_buf[IBUFSIZE]; /* input character buffer */
int in_next = 0; /* pos to retrieve next input character */
int in_last = 0; /* pos to place most recent input character */
in_init() /* initialize the input buffer */
{
in_next = in_last = 0;
}
in_check() /* is the input buffer non-empty? */
{
if (in_next == in_last)
return(FALSE);
else
return(TRUE);
}
in_put(event)
int event; /* event to enter into the input buffer */
{
in_buf[in_last++] = event;
in_last &= (IBUFSIZE - 1);
}
int in_get() /* get an event from the input buffer */
{
register int event; /* event to return */
event = in_buf[in_next++];
in_next &= (IBUFSIZE - 1);
return(event);
}
void init_aline()
{
int *ld_contrl;
int *ld_intin;
linea0();
/* save if the current mouse is hidden (ie we are not in GEM) */
gemflag = (mousehidden == 0);
while (mousehidden) {
showmouse();
}
aline = (struct la_data *)(la_init.li_a0);
fonts = (struct la_font **)(la_init.li_a1);
naline = ((struct la_ext *)aline) - 1;
scursor = naline->ld_status; /* State of text cursor */
ld_contrl = aline->ld_contrl; /* -> control junk */
ld_intin = aline->ld_intin; /* -> intin junk */
}
init()
{
init_aline();
system_font = fonts[SCRFONT]; /* save it */
small_font = fonts[1];
}
switch_font(fp)
struct la_font *fp;
{
/* See linea.h for description of fields */
V_CEL_HT = fp->font_height;
V_CEL_WR = aline->ld_vwrap * fp->font_height;
V_CEL_MY = (naline->ld_y_max / fp->font_height) - 1;
V_CEL_MX = (naline->ld_x_max / fp->font_fat_cell) - 1;
V_FNT_WR = fp->font_width;
V_FNT_ST = fp->font_low_ade;
V_FNT_ND = fp->font_hi_ade;
V_OFF_AD = (long) fp->font_char_off;
V_FNT_AD = (long) fp->font_data;
}
stmove(row, col)
{
stputc(ESC);
stputc('Y');
stputc(row+BIAS);
stputc(col+BIAS);
}
steeol()
{
stputc(ESC);
stputc('K');
}
steeop()
{
#if COLOR
stfcol(gfcolor);
stbcol(gbcolor);
#endif
stputc(ESC);
stputc('J');
}
strev(status) /* set the reverse video state */
int status; /* TRUE = reverse video, FALSE = normal video */
{
if (currez > 1) {
stputc(ESC);
stputc(status ? 'p' : 'q');
}
}
#if COLOR
mapcol(clr) /* medium rez color translation */
int clr; /* emacs color number to translate */
{
static int mctable[] = {0, 1, 2, 3, 2, 1, 2, 3};
if (currez != 1)
return(clr);
else
return(mctable[clr]);
}
stfcol(color) /* set the forground color */
int color; /* c